﻿using System;
using System.Collections.Generic;
using System.Text;

namespace SqlSugarEncapsulation.Common
{
    public class DBValueUtil
    {
        public static string GetDBNullString(object value)
        {
            if ((value == DBNull.Value || value == null)) return null;
            return value.ToString();
        }

        public static DateTime? GetDBNullDatetime(object value)
        {
            if ((value == DBNull.Value || value == null)) return null;
            return DateTime.Parse(value.ToString());
        }

        public static int? GetDBNullInt(object value)
        {
            if ((value == DBNull.Value || value == null)) return null;
            return int.Parse(value.ToString());
        }

        public static double? GetDBNullDouble(object value)
        {
            if ((value == DBNull.Value || value == null)) return null;
            return double.Parse(value.ToString());
        }

        public static decimal? GetDBNullDecimal(object value)
        {
            if ((value == DBNull.Value || value == null)) return null;
            return decimal.Parse(value.ToString());
        }
    }
}
